package com.ruoyi.hualian.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hualian.domain.HlBearing;
import com.ruoyi.hualian.service.IHlBearingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 轴承型号Controller
 * 
 * @author hujian
 */
@RestController
@RequestMapping("/hualian/bearing")
public class HlBearingController extends BaseController
{
    @Autowired
    private IHlBearingService hlBearingService;

    /**
     * 查询轴承型号列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:bearing:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlBearing hlBearing)
    {
        startPage();
        List<HlBearing> list = hlBearingService.selectHlBearingList(hlBearing);
        return getDataTable(list);
    }

    /**
     * 导出轴承型号列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:bearing:export')")
    @Log(title = "轴承型号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlBearing hlBearing)
    {
        List<HlBearing> list = hlBearingService.selectHlBearingList(hlBearing);
        ExcelUtil<HlBearing> util = new ExcelUtil<HlBearing>(HlBearing.class);
        util.exportExcel(response, list, "轴承型号数据");
    }

    /**
     * 获取轴承型号详细信息
     */
    @PreAuthorize("@ss.hasPermi('hualian:bearing:query')")
    @GetMapping(value = "/{bearingId}")
    public AjaxResult getInfo(@PathVariable("bearingId") Long bearingId)
    {
        return success(hlBearingService.selectHlBearingByBearingId(bearingId));
    }

    /**
     * 新增轴承型号
     */
    @PreAuthorize("@ss.hasPermi('hualian:bearing:add')")
    @Log(title = "轴承型号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlBearing hlBearing)
    {
        return toAjax(hlBearingService.insertHlBearing(hlBearing));
    }

    /**
     * 修改轴承型号
     */
    @PreAuthorize("@ss.hasPermi('hualian:bearing:edit')")
    @Log(title = "轴承型号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlBearing hlBearing)
    {
        return toAjax(hlBearingService.updateHlBearing(hlBearing));
    }

    /**
     * 删除轴承型号
     */
    @PreAuthorize("@ss.hasPermi('hualian:bearing:remove')")
    @Log(title = "轴承型号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bearingIds}")
    public AjaxResult remove(@PathVariable Long[] bearingIds)
    {
        return toAjax(hlBearingService.deleteHlBearingByBearingIds(bearingIds));
    }
}
